import request from '@/utils/request'
const prefixUrl = '/api/login'
const interestUrl = '/api/admin/interest'
const collectUrl = '/api/admin/collect'
const prefixUser = '/api/user'

// 用户信息
export function getInfo() {
	return request({
		url: `${prefixUrl}/getInfo`,
		method: 'get'
	})
}
//关注列表
export function interestList(params) {
	return request({
		url: `${interestUrl}/list`,
		method: 'get',
		params: params
	})
}
/**
 * 我的收藏
 */
export function collectList(params) {
	return request({
		url: `${collectUrl}/list`,
		method: 'get',
		params: params
	})
}

//取消收藏
export function delCollect(id) {
	return request({
		url: `/api/admin/collect/delete/${id}`,
		method: 'delete',
	})
}

/**
 * 我邀请的用户
 */
export function inviteList(params) {
	return request({
		url: '/api/invite/list',
		method: 'get',
		params: params
	})
}
/**
 * @param {Object} 
 * 我的咨询
 */
export function consultList(params) {
	return request({
		url: '/api/webContact/list',
		method: 'get',
		params: params
	})
}
/**
 * 咨询详情
 * @param id
 * @returns {*}
 */
export function consulInfo(id) {
	return request({
		url: `/api/webContact/info/${id}`,
		method: 'get',
	})
}
/**
 * 讲师意向确认
 * @returns {*}
 */
export function examine(id, status) {
	return request({
		url: `/api/webContact/examine/${id}/${status}`,
		method: 'put',
	})
}
/**
 * 修改资料
 * @param {Object} data
 */
export function editInfo(data) {
	return request({
		url: '/api/user/editUser',
		method: 'put',
		data: data
	})
}
/**
 * 我报名的公开课
 * @param params
 * @returns {AxiosPromise}
 */
export function registeredList(params) {
	return request({
		url: '/api/openCourse/registered',
		method: 'get',
		params: params
	})
}
/**
 * 添加评论
 * @param id
 * @returns {AxiosPromise}
 */
export function addEvaluate({
	id,
	content,
	rate,
	type
}) {
	return request({
		url: `/api/evaluate/add`,
		method: 'post',
		data: {
			type: type,
			unionId: id,
			content: content,
			rate: rate
		}
	})
}
/**
 * 修改密码
 * @param {Object} params
 */
export function updatePwd(params) {
	return request({
		url: '/system/user/profile/updatePwd',
		method: 'PUT',
		params: params

	})
}

/**
 * 普通用户入驻成为讲师
 */
export function joinTeacherInfo(userType) {
    return request({
    	url: `${prefixUser}/joinTeacher/${userType}`,
    	method: 'post',
    })
}

/**
 * @param {Object} 用户注册
 */
export function register(data) {
  return request({
    url: '/api/user/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}